$(() => {
	var tel = $("#tel"),
		psd = $("#psd"),
		telWarning = $(".tel-warning"),
		psdWarning = $(".psd-warning"),
		signIn = $("#signIn"),
		signUp = $("#signUp");
		tel.on('blur', () => {
			checkPhone()
		})
		psd.on('keyup', () => {
			checkPassword()
		})
		psd.on('blur', () => {
			checkPassword()
		})
		signIn.on('click', () => {
			if (!checkPhone()) {
				alert('请检查电话号码是否输入正确')
			} else if (!checkPassword()) {
				alert('请检查密码是否输入正确')
			} else {
				// 进入ajax
			}
		})
		signUp.on('click', () => {
			if (!checkPhone()) {
				alert('请检查电话号码是否输入正确')
			} else if (!checkPassword()) {
				alert('请检查密码是否输入正确')
			} else {
				// 进入ajax
			}
		})
		// 电话号码验证
		var checkPhone = () => {
			    let phone =tel.val();
			    if (!(/^1[3456789]\d{9}$/.test(phone))){
			    	telWarning.text('请输入11位正确的电话号码');
			    	return false;
			    } else {
			    	telWarning.text('');
			    	return true
			    }
		}
		// 密码验证
		var checkPassword = () => {
			let psdChecked = psd.val().trim();
		    //密码为八位及以上并且字母数字特殊字符三项都包括
		    var strongRegex = new RegExp("^(?=.{8,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*\\W).*$", "g");
		    //密码为七位及以上并且字母、数字、特殊字符三项中有两项，强度是中等
		    var mediumRegex = new RegExp("^(?=.{7,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))).*$", "g");
		    var enoughRegex = new RegExp("(?=.{6,}).*", "g");
		    if (!enoughRegex.test(psdChecked)) {
		    	psdWarning.text('密码最小为6位');
		    	return false;
		    } else if (strongRegex.test(psdChecked)) {
		         psdWarning.text('密码强度强');
		         return true;
		    } else if (mediumRegex.test(psdChecked)) {
		        psdWarning.text('密码强度中');
		        return true;
		    } else {
		        psdWarning.text('密码强度弱');
		        return true;
		    }
		}
})